#!/usr/bin/php
<?php

set_include_path(dirname(__FILE__) . '/../src/');

require_once 'Pipes/CommandLine/ArgumentParser.php';
require_once 'Pipes/FileSystem/Directory.php';
require_once 'Pipes/Generator/Start.php';
require_once 'Pipes/Generator/Create.php';

$action = $argv[1];
$argument = $argv[2];
$rootPath = new Pipes_FileSystem_Directory(getcwd());
switch ($action) {
    case 'start' :
        $schema = array(
            '--disable-database' => array(
                'name' => 'disable_database',
                'type' => 'bool'
            ),
        );
        $parser = new Pipes_CommandLine_ArgumentParser($schema);

        $starter = new Pipes_Generator_Start($rootPath, $parser->parse($argv));
        $starter->start($argument);
        break;

    case 'create' :
        $schema = array(
            '--with' => array(
                'name'      => 'with',
                'pattern'   => Pipes_CommandLine_ArgumentParser::PATTERN_WITH,
                'type'      => 'array',
            )
        );
        $parser = new Pipes_CommandLine_ArgumentParser($schema);

        $config = new Pipes_Config('./config.php');
        $creator = new Pipes_Generator_Create($config, $rootPath->toString());
        $creator->create($argument, $parser->parse($argv));
        break;

    default:
        echo <<< END
Congratulations!  Pipes is successfully installed.

To start a project, run: 
    \$ pipes start <ProjectName>

To create basic MVC scaffolding, switch to the <ProjectName> directory and run: 
    \$ pipes create <ModelName>


END;
        break;
}
